package com.wh.autoconfig.starter;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther: HuiEr
 * @Date: 2020/2/20 22:07
 * @Description
 */
@Configuration
@ConditionalOnClass(DeptService.class)
@EnableConfigurationProperties(DeptServiceProperties.class)
public class DeptServiceAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public DeptService deptService(DeptServiceProperties deptServiceProperties){
        return new DeptService(deptServiceProperties.getDeptName(),deptServiceProperties.getDeptDes());
    }
}
